var mongoose = require('mongoose');

mongoose.set('useFindAndModify', false)
mongoose.connect('mongodb://localhost/SunRan',{useNewUrlParser: true,useUnifiedTopology:true,});

var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
//构建users的model
var usersSchema = mongoose.Schema({
    username: String,
    Tel:Number,
    role:String,
    salary:Number,
    state:String,//状态
});
var adminsSchema = mongoose.Schema({
    username: String,
    password:String,
    email:String,
    position:String,

});
var financeSchema = mongoose.Schema({
    money: Number,
    amountMoney:String,
    department:String,
});
var equipmentSchema = mongoose.Schema({
    DeviceName: String,
    state:String,
    PurchaseDate:Date,
    money:Number,
    num:Number,
});
var receptionSchema = mongoose.Schema({
    Customerlist: String,
    identity:String,
    affair:String,
    speedprogress:String,
});




var Users = mongoose.model('users', usersSchema);
var Admins = mongoose.model('admins', adminsSchema);
var Finance = mongoose.model('finances', financeSchema);
var Equipments = mongoose.model('equipments', equipmentSchema);
var Receptions = mongoose.model('receptions', receptionSchema);

exports.Users = Users
exports.Admins = Admins
exports.Finance = Finance
exports.Equipments = Equipments
exports.Receptions = Receptions
